<template>
  <div>
    <div ref="myRef">111</div>
    <button @click="seve">获取ref</button>
  </div>
</template>

<script>
import { reactive, ref, toRefs } from "vue";
export default {
  name: "",
  // 定义模板
  components: {},
  //在创建组件之前执行
  setup(props, context) {
    const state = reactive({
      name: "你好",
    });
    const num = ref(0);
    const myRef = ref(null);

    const seve = () => {
      console.log(myRef.value);
    };

    return {
      ...toRefs(state),
      num,
      myRef,
      seve,
    };
  },
};
</script>
<style scoped lang ='less'>
</style>